package za.co.johanmynhardt.jee.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * @author johan.mynhardt@thumbtribe.mobi
 * @version 2011.0720
 *          Time: 10:09 PM
 */
@Entity
public class Comment implements Serializable {
	private Long id;
	private User user;
	private String comment;
	private Date date;

	@GeneratedValue( strategy = GenerationType.IDENTITY)
	@Id
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@OneToOne
	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public String getComment() {
		return comment;
	}

	public void setComment(String comment) {
		this.comment = comment;
	}

	@Temporal(value = TemporalType.TIMESTAMP)
	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	@Override
	public String toString() {
		return String.format("Post: {id=%s, date=%s, user=%s, comment=%s}", getId(), getDate(), getUser(), getComment());
	}
}
